package cn.maihe.elg.operation.repository.entity;

import cn.maihe.elg.operation.repository.entity.AcceptContentVo;
import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 受理订单的请求报文
 */
@TableName("t_accept_content")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.AcceptContentMapper")
public class AcceptContent extends BaseEntity {
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 受理订单号
     */
    @TableField(value = "accept_order_no")
    private String acceptOrderNo;

    /**
     * 承保申请全字段json
     */
    @TableField(value = "req_content")
    private String reqContent;

    public AcceptContentVo buildVo() {
        return new AcceptContentVo(id, acceptOrderNo, reqContent);
    }

    public static AcceptContent of(AcceptContentVo vo) {
        return new AcceptContent(vo.getId(), vo.getAcceptOrderNo(), vo.getReqContent());
    }
}
